package com.example.leetcode;

/**
 * 动态规划
 * 不同路径
 * f(i)(j)=f(i-1)(j)+f(i)(j-1);
 */
public class Demo0062 {
    public int uniquePaths(int m, int n) {
        int [][] f=new int[m][n];
        f[0][0]=1;
        for (int i = 0; i < m; i++) {
            for (int j = 0; j < n; j++) {
                f[i][j]+=((i-1)>=0?f[i-1][j]:0);
                f[i][j]+=((j-1)>=0?f[i][j-1]:0);
            }
        }
        return f[m-1][n-1];
    }
}
